﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class communication2 : MonoBehaviour
{

    public GameObject dialogBox1;
    public GameObject dialogBox2;
    public Text dialogBoxText1;
    public Text dialogBoxText2;
   
    public GameObject continueButton;
    public GameObject eventSystem3;
    public string[] signText = new string[] { "看，有客人来了，快去接待他吧" };
    private bool toNextText;
    private string currentText;
    private int currentNum = 0;
    private int length;
    public bool isfirst = true;
    private bool judgeArrow = true;


    private void Awake()
    {
        length = signText.Length;
        currentText = signText[currentNum];
    }


    // Start is called before the first frame update
    void Start()
    {
        dialogBox1.SetActive(true);

        if (isfirst)
        {
            dialogBoxText1.text = currentText;
        }
        isfirst = false;

    }

    // Update is called once per frame
    void Update()
    {


        // dialogBoxText.text = currentText;

        if (Input.GetMouseButtonDown(0))   //0代表鼠标左键 1是右键
        {
            eventSystem3.SetActive(true);
            currentNum = currentNum + 1;
            if (currentNum < length)
            {

                if (currentNum % 2 == 0)
                {
                    dialogBox1.SetActive(true);
                    dialogBox2.SetActive(false);

                    Debug.Log(currentNum + "情况1");
                    currentText = signText[currentNum];
                    dialogBoxText1.text = currentText;
                }
                if (currentNum % 2 == 1)
                {
                    dialogBox1.SetActive(false);
                    dialogBox2.SetActive(true);

                    Debug.Log(currentNum + "情况2");
                    currentText = signText[currentNum];
                    dialogBoxText2.text = currentText;
                }

               

            }
            else
            {


                dialogBox1.SetActive(false);


                dialogBox2.SetActive(false);
           
                judgeArrow = false;
                continueButton.SetActive(!judgeArrow);
                Debug.Log("对话内容完");
                eventSystem3.SetActive(true);
            }

        }
    }





}
